const Base = require('../controller/base.js');

module.exports = class extends think.Logic {
    async __before() {
        let authority = 'ROLE_SUPER_ADMIN';
        let attribute = await this.session('attribute');
        try {
            if (authority == attribute.authority ||attribute.authority=='ROLE_ADMIN') {
                return;
            } else {
                return this.fail('403', '权限不够，无法访问！');
            }
        } catch (e) {
            return this.redirect('/index/index');       //没有取到权限authority，代表session过期，直接跳转到登录页面
        }
    }
}
;
